//
//  VerticalCenterButton.m
//  WidgetDemo
//
//  Created by 航汇聚科技 on 2017/12/29.
//  Copyright © 2017年 Yi Zhou. All rights reserved.
//

#import "VerticalCenterButton.h"

@implementation VerticalCenterButton

-(void)layoutSubviews {
    [super layoutSubviews];
    
    // 图片居中
    CGPoint center = self.imageView.center;
    center.x = self.frame.size.width/2;
    center.y = self.imageView.frame.size.height/2+5;
    self.imageView.center = center;
    
    // 文字居中
    CGRect newFrame = [self titleLabel].frame;
    newFrame.origin.x = 0;
    newFrame.origin.y = CGRectGetMaxY(self.imageView.frame) + 2;
    newFrame.size.width = self.frame.size.width;
    self.titleLabel.frame = newFrame;
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
}

@end
